"""
URL configuration for app project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/5.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, re_path
from api import views

urlpatterns = [
    # path('admin/', admin.site.urls),

    path('home/', views.home),
    path('login/', views.LoginView.as_view()),
    path('user/', views.UserView.as_view()),
    path('order/', views.OrderView.as_view()),
    path('getVersion/', views.GetVersionView.as_view(), name="GETVERSION"),
    # path('api/<str:version>/getVersion/', views.ApiGetVersionView.as_view(), name="APIGETVERSION"),
    re_path(r'^api/(?P<version>\w+)/getVersion/', views.ApiGetVersionView.as_view(), name="APIGETVERSION"),
    # 解析器
    path('api/<str:version>/parser/', views.ParserView.as_view(), name="PARSERVIEW"),
    path('api/<str:version>/img/', views.ImgView.as_view(), name="IMG"),

    # 数据序列化
    path('api/userList/', views.UserListViews.as_view(), name="USERLIST"),
    path('api/userList2/', views.UserList2Views.as_view(), name="USERLIST2"),
    path('api/user/create/', views.UserList3Views.as_view(), name="USERLIST3"),  # 创建用户
    path('api/department/', views.DepartmentViews.as_view(), name="DEPARTMENT"),

    path('api/dp/', views.DpViews.as_view()),
    path('api/uus/', views.UusViews.as_view()),

    path('api/nbuser/', views.NbUserViews.as_view()),
    # 博客系统
    path("createTestData/", views.createTestData),
    # 获取博客列表
    path("api/blog/", views.BlogViews.as_view()),
    # 获取博客详情
    path("api/blog/<int:pk>/", views.BlogDetailsViews.as_view()),
    # 获取博客评论列表 S
    path("api/comment/<int:blog_id>/", views.BlogCommentViews.as_view()),
    # 点赞
    path("api/favor/", views.BlogFavorViews.as_view()),
    # 获取博客评论列表 E
    # 用户注册
    path("api/user/register/", views.UserRegisterView.as_view()),
    path("api/user/login/", views.UserLoginView.as_view()),

    #
    path("api/book/", views.BookView.as_view()),
    re_path("api/book/(\d+)", views.BookDetailView.as_view()),
    # 这种是 无名分组

    path("api/bookV2/", views.BookV2View.as_view()),
    re_path("api/bookV2/(?P<pk>\d+)", views.BookV2DetailView.as_view()),
    # re_path("api/bookV2/(?P<id>\d+)", views.BookV2DetailView.as_view()),
    # 这种是有名分组
    path("api/bookV3/", views.BookV3View.as_view()),
    re_path("api/bookV3/(?P<pk>\d+)", views.BookV3DetailView.as_view()),
    # re_path("api/bookV3/(?P<id>\d+)", views.BookV3DetailView.as_view()),
    # 这种是有名分组
    path("api/bookV4/", views.BookV4View.as_view()),
    re_path("api/bookV4/(?P<id>\d+)", views.BookV4DetailView.as_view()),
    # re_path("api/bookV3/(?P<id>\d+)", views.BookV4DetailView.as_view()),
    # 这种是有名分组

    path("api/bookV5/", views.BookV5View.as_view({"get": "get_all", "post": "add_object"})),
    re_path("api/bookV5/(?P<id>\d+)",
            views.BookV5View.as_view({"get": "get_object", "put": "update_object", "delete": "delete_object"})),

    path("api/bookV6/", views.BookV6View.as_view({"get": "list", "post": "create"})),
    re_path("api/bookV6/(?P<id>\d+)",
            views.BookV6View.as_view(
                {"get": "retrieve", "put": "update", "patch": "partial_update", "delete": "destroy"})),

    path("api/bookV7/", views.BookV7View.as_view({"get": "list", "post": "create"})),
    re_path("api/bookV7/(?P<id>\d+)",
            views.BookV7View.as_view(
                {"get": "retrieve", "put": "update", "patch": "partial_update", "delete": "destroy"})),
]

# 自动注册路由
from rest_framework import routers

router = routers.SimpleRouter()
router.register("api/bookV8", views.BookV7View, basename="bookV8")
# 生成路由表-汇总
urlpatterns += router.urls
# 获取生成好的路由信息
print(router.urls)
